#-*- coding: utf-8 -*-
#开发团队:全能战队
#开发人员:liang.liu
#开发时间:2019/11/26 18:35
#文件名称:sqlite3_test.py
#开发工具:PyCharm

import sqlite3
# 连接到SQLite数据库
# 数据库文件是mrsoft.db，如果文件不存在，会自动在当前目录创建
conn = sqlite3.connect('mrsoft.db')
#创建一个cursor
cursor = conn.cursor()
#执行一条SQL语句，创建user表
# try:
#cursor.execute('create table user(id int(10) primary key, name varchar(20))')
# except:
# cursor.execute('insert into user (id,name) values ("1","MRSOFT")')
# cursor.execute('insert into user (id,name) values ("2","Andy")')
# cursor.execute('insert into user (id,name) values ("3","明日科技小助手")')
cursor.execute('select * from user')
result1 = cursor.fetchone()
print(result1)
# result2 = cursor.fetchmany(2)
# print(result2)
# result3 = cursor.fetchall()
# print(result3)
#关闭游标
cursor.close()
#关闭Connection
conn.close()